package com.design.pattern.create.factory.simple;

import com.design.pattern.entry.Fruit;
import com.design.pattern.entry.fruit.Apple;
import com.design.pattern.entry.fruit.Banana;
import com.design.pattern.entry.fruit.Orange;

/**
 * 简单工厂模式：静态工厂
 *
 * @author gyf
 * @create 2018-11-30 14:22
 **/
public class SimpleFactory {
    public static final int TYPE_APPLE = 1;
    public static final int TYPE_ORANGE = 2;
    public static final int TYPE_BANANA = 3;

    public static Fruit getFruit(int type) {
        if (TYPE_APPLE == type) {
            return new Apple();
        } else if (TYPE_ORANGE == type) {
            return new Orange("gyf", 80);
        } else if (TYPE_BANANA == type) {
            return new Banana();
        }
        return null;
    }

    /**
     * 多方法工厂
     *
     * @return fruit
     */
    public static Fruit getApple() {
        return new Apple();
    }

    public static Fruit getOrange() {
        return new Orange("gyf", 100);
    }

    public static Fruit getBanana() {
        return new Banana();
    }
}
